package com.xh.core.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/*
 * @Author daiwei
 * @Description
 * @Date 2019/1/15 13:36
 **/
public class RegexUtils {

    /**
     * 是否符合正则表达式
     * @param data
     * @param pattern
     * @return
     */
    public static boolean Match(String data, String pattern){
        Pattern r = Pattern.compile(pattern);
        Matcher m= r.matcher(data);
        return m.find();
    }

    /**
     * 获取正则匹配的Matcher
     * @param data
     * @param pattern
     * @return
     */
    public static Matcher getMatcher(String data,String pattern){
        Pattern r = Pattern.compile(pattern);
        Matcher m= r.matcher(data);
        return m;
    }

    public static boolean isMobile(String mobile){
        return Match(mobile,"^1\\d{10}$");
    }
}
